#!/usr/bin/env node

const log = console.log,
      http = require('http'),
      addr = process.argv[2] || 'http://sample.wangding.in/web/one-div.html';

http.get(addr,(res)=>{
  //print respnd start line
  //HTTP/1.1 200 OK
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  
  //print respond header
  //Content-Length:22
  log(res.headers)
  res.pipe(process.stdout);

  //print respond body
  let data;
  res.on('data',(chunk)=>{
    data+=chunk;
  });

  res.on('end',()=>{
    log(data);
  })

});

